const path = require('path');
const fs = require('fs');

const checkInstallPath = () =>
  new Promise((resolve, reject) => {
    if (global.cwdPath) {
      const localPath = path.join(global.cwdPath, 'node_modules/yh-page');
      const isLocalInstalled = fs.existsSync(localPath);
      resolve(isLocalInstalled ? 'local' : 'global');
    }
    reject(new Error());
  });

module.exports = checkInstallPath;
